unit Con_Pais_Banco;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, Grids, DBGrids, StdCtrls, Buttons, ExtCtrls,
  Db, DbTables;

type
  TFrmCon_Banco = class(TFrmConsulta)
    Label1: TLabel;
    edtNome: TEdit;
    dbgBanco: TDBGrid;
    procedure BtnFecharClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure edtNomeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure btnBuscaClick(Sender: TObject);
  private
    { Private declarations }
    procedure FazConsulta;
  public
    { Public declarations }
    Banco_Codigo : String;
  end;

var
  FrmCon_Banco: TFrmCon_Banco;

implementation
Uses Dm, Biblio, clsBanco;

{$R *.DFM}

var Banco           : TBanco;
    tds            : Tdatasource;
    tq             : Tquery;

procedure TFrmCon_Banco.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Banco_Codigo:=tq.fieldbyname('Banco_Codigo').asstring;
  tds.free;
  tq.free;
end;

procedure TFrmCon_Banco.FazConsulta;
begin
  if edtnome.text='' then
    edtnome.text := ' ';
  Banco:=TBanco.Create;
  Banco.Consultar(tq,edtnome.text);
  tq.open;
  Banco.free;
  dbgBanco.DataSource := tds;
  dbgBanco.Refresh;
end;

procedure TFrmCon_Banco.FormActivate(Sender: TObject);
begin
  inherited;
  tds:=TDataSource.create(FrmCon_Banco);
  tds.name:='dsBanco';
  tq:=Tquery.create(FrmCon_Banco);
  tq.databasename:=dm.dmint.db.databasename;
  tq.name:='qBanco';
  tq.active:=False;
  tds.DataSet:=tq;
  fazconsulta;
  edtnome.setfocus;
end;

procedure TFrmCon_Banco.edtNomeKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  inherited;
  if key=12 then begin
    FazConsulta;
    edtNome.setfocus;
  end;
end;

procedure TFrmCon_Banco.btnBuscaClick(Sender: TObject);
begin
  inherited;
  FazConsulta;
  edtNome.setfocus;
end;

end.
